<?php
/**
 * Created by PhpStorm.
 * User: trnall
 * Date: 2019/9/24
 * Time: 19:02
 */

/*namespace wechat\wxpay;

use wechat\wxpay\lib\WxPayNotify;
use app\api\service\v1\RechargeService;

class WechatNotify extends WxPayNotify
{
    public function Queryorder($transaction_id)
    {
        $input = new \WxPayOrderQuery();
        $input->SetTransaction_id($transaction_id);
        $result = \WxPayApi::orderQuery($input);
        if (array_key_exists("return_code", $result)
            && array_key_exists("result_code", $result)
            && $result["return_code"] == "SUCCESS"
            && $result["result_code"] == "SUCCESS") {
            return true;
        }
        return false;
    }

    public function NotifyProcess($data, &$msg)
    {
        //查询订单，判断订单真实性
//        $ext = substr($data["out_trade_no"], 0, 2);
        if (!$this->Queryorder($data["transaction_id"])) {
            return false;
        }
        if (array_key_exists('return_code', $data) && array_key_exists('result_code', $data) && $data['result_code'] == 'SUCCESS') {
            return RechargeService::notify($data);
        }
        return false;
    }
}*/